using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using Comteck.Entities.Goods;
using Comteck.Entities.Orders;
using Comteck.Entities.Sys;
using Comteck.Entities.Users;

namespace Comteck.Ktt.Services {
  /// <summary>
  /// https://www.leavescn.com/Articles/Content/3497
  /// </summary>
  public class AppDbContext : DbContext {
    /// <summary>
    /// 
    /// </summary>
    static AppDbContext() {
      Database.SetInitializer(new MigrateDatabaseToLatestVersion<AppDbContext, MigratorConfiguration>(true));
    }

    public AppDbContext() : base("name=DefaultConnection") {
      this.Configuration.AutoDetectChangesEnabled = false;
      this.Configuration.ValidateOnSaveEnabled = false;
      this.Configuration.ProxyCreationEnabled = false;
      this.Configuration.LazyLoadingEnabled = false;

      
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder) {
      modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
      base.OnModelCreating(modelBuilder);
    }

    public DbSet<User> Users { get; set; }
    public DbSet<MenuAuth> MenuAuth { get; set; }
    public DbSet<Product> Product { get; set; }
    public DbSet<SelfOrg> SelfOrg { get; set; }
    public DbSet<SelfOrgTag> SelfOrgTag { get; set; }
    public DbSet<SelfOrgTagRelation> SelfOrgTagRelation { get; set; }
    public DbSet<SaleOrder> SaleOrder { get; set; }
    public DbSet<Parameter> Parameter { get; set; }
    public DbSet<SaleOrderDetail> SaleOrderDetail { get; set; }
    public DbSet<SaleOrderPath> SaleOrderPath { get; set; }
    public DbSet<PrintTemplate> PrintTemplate { get; set; }
    public DbSet<PrintTemplateData> PrintTemplateData { get; set; }
  }
}
